package com.eduhzy.ttw.teacher.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.eduhzy.ttw.commonsdk.decoration.DividerItemDecoration;
import com.eduhzy.ttw.teacher.mvp.model.entity.ChooseSchoolData;
import com.eduhzy.ttw.commonsdk.holder.AutoBaseViewHolder;
import com.eduhzy.ttw.teacher.R;
import com.eduhzy.ttw.teacher.mvp.contract.ChooseSchoolContract;
import com.eduhzy.ttw.teacher.mvp.model.ChooseSchoolModel;
import com.jess.arms.di.scope.ActivityScope;
import com.mcxtzhang.indexlib.suspension.SuspensionDecoration;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

/**
 * @author xubo
 * @date 2018-7-19 10:06:17
 */
@Module
public abstract class ChooseSchoolModule {

    @Binds
    abstract ChooseSchoolContract.Model bindChooseSchoolModel(ChooseSchoolModel model);

    @ActivityScope
    @Provides
    static List<ChooseSchoolData> provideList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static BaseQuickAdapter<ChooseSchoolData, AutoBaseViewHolder> provideActivityAdapter(List<ChooseSchoolData> list) {
        return new BaseQuickAdapter<ChooseSchoolData, AutoBaseViewHolder>(R.layout.rv_item_choose_area, list) {
            @Override
            protected void convert(AutoBaseViewHolder helper, ChooseSchoolData item) {
                helper.setText(R.id.tv_name, item.getName());
            }

        };
    }

    @ActivityScope
    @Provides
    static SuspensionDecoration provideSuspensionDecoration(ChooseSchoolContract.View view, List<ChooseSchoolData> list) {
        return new SuspensionDecoration(view.getActivity(), list);
    }

    @ActivityScope
    @Provides
    static DividerItemDecoration provideDividerItemDecoration(ChooseSchoolContract.View view, List<ChooseSchoolData> list) {
        return new DividerItemDecoration(view.getActivity(), DividerItemDecoration.VERTICAL_LIST);
    }

    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideLayoutManger(ChooseSchoolContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }


}